import DList from "@/components/dlist";
export default {
  data() {
    return {
      state: "yes",
      checked: false,
      tabList: [{
        name: "已上架",
        value: "yes"
      },{
        name: "待审核",
        value: "wait"
      },{
        name: "审核驳回",
        value: "close"
      }],
      loading: false,
      finished: false,
      page: 1,
      dataList: []
    };
  },
  mounted() {
    this.getDataList();
  },
  methods: {
    goDemandPage(id) {
      this.$router.push(
        this.fun.getUrl("anyDemandPublish", {type:'check' , id})
      );
    },
    async getDataList() {
      if (this.loading === true || this.finished === true) {
        return;
      }
      this.loading = true;
      let { data, result, msg } = await $http.get("plugin.be-within-call.frontend.enterprise.need", { state:this.state,page: this.page});
      if (result === 0) {
        this.$toast(msg);
        return;
      }
      if (data.data.length === 0 || data.data.length < data.per_page || data.current_page === data.last_page) {
        this.finished = true;
      }
      this.total = data.total;
      this.dataList.push(...data.data);
      this.page++;
      this.loading = false;
    },
    onLoad() {
      this.getDataList();
    },
    clickTab(ev) {
      console.log(ev,11111111111);
      this.loading = false;
      this.finished = false;
      this.page = 1;
      this.dataList = [];
      this.getDataList();
    },
    clickSwitch(ev,item) {
      $http.get("plugin.be-within-call.frontend.enterprise.need-hide-switch", { is_hide: item.is_hide == 1 ? 0 : 1 , id: item.id }).then(({ data , result , msg }) => {
        this.$toast(msg);
      });
    },
    checkOrder(order_id) {
      this.$router.push(
        this.fun.getUrl("anyOrderDetail", {type: "enterprise",order_id})
      );
    }
  },
  components: { DList }
};
